package cn.tedu.imop.basic.dao.repository.impl;

import cn.tedu.imop.basic.dao.mapper.MemberMapper;
import cn.tedu.imop.basic.dao.repository.MemberRepository;
import cn.tedu.imop.basic.entity.Member;
import cn.tedu.imop.common.context.PageContext;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.common.utils.PageInfoToPageDataConverter;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MemberRepositoryImpl implements MemberRepository {//is a
    private MemberMapper memberMapper;
    @Autowired
    public MemberRepositoryImpl(MemberMapper memberMapper) {
        this.memberMapper = memberMapper;
    }
    @Override
    public int insertMember(Member member) {
        int rows=memberMapper.insert(member);
        return rows;
    }

    @Override
    public PageData<Member> selectMemberList(Member member) {
        PageContext.startPage();
        List<Member> list=memberMapper.selectList(member);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(list));
    }
}
